package union

import (
	"jlpay-sdk-go/pkg/jlpay/core"
	"jlpay-sdk-go/pkg/jlpay/models/trans/union"
	"jlpay-sdk-go/pkg/jlpay/services"
)

// UnionJsPayService 银联JS支付服务
type UnionJsPayService struct {
	*services.BaseService
}

// NewUnionJsPayService 创建银联JS支付服务
func NewUnionJsPayService(config *core.Config) *UnionJsPayService {
	return &UnionJsPayService{
		BaseService: services.NewBaseService(config),
	}
}

// UnionJsPay 银联JS支付
func (s *UnionJsPayService) UnionJsPay(request *union.UnionJsPayRequest) (*union.UnionJsPayResponse, error) {
	response := union.NewUnionJsPayResponse()
	err := s.Post(request, response, "/open/trans/unionjspay")
	if err != nil {
		return nil, err
	}
	return response, nil
}
